<?php

namespace app\common\model\customer;

use app\common\model\company\Company;
use think\Model;

class AllocationLog extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'allocation_log';
    protected $pk    = 'Id';

    public function getAddTimeAttr($value)
    {
        return date('Y-m-d H:i:s', $value);
    }

    // 查询分配记录
    public function getLists($where) {
        $data = $this->where($where)->order('AddTime desc')->select();
        return $data;
    }
    // 添加分配记录
    public function addAllocationLog($data, $OperatorId){
        $t = time();
        $this->OperatorId = $OperatorId;
        $this->CId = $data['CId'];
        $this->BussinessId = $data['BussinessId'];
        $this->OldBussinessId = isset($data['OldBussinessId'])?$data['OldBussinessId']: '';
        $this->AddTime = $t;
        $this->save();
        $rst = [
            'Id' => $this->Id,
        ];
        return $rst;
    }
}
